#include <iostream>
using namespace std;
string encode() {
  char ch;
  string res;
  while (cin >> ch) {
    if (ch == '[') {
      int x;
      cin >> x;
      string temp = encode();
      while (x--) res += temp;
    } else if (ch == ']') {
      return res;
    } else {
      res += ch;
    }
  }
  return res;
}
int main() {
  cout << encode() << endl;
}